package com.cjf.spring.cloud.weather.controller;

import com.cjf.spring.cloud.weather.service.WeatherDataService;
import com.cjf.spring.cloud.weather.vo.WeatherResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
* @description 
* @author  cjf
* @create 2019-03-26 17:46
*/
@RestController
@RequestMapping("/weather")
public class WeatherController  {

    @Autowired
    private WeatherDataService weatherDataService;

    @GetMapping("/cityId/{cityId}")
    public WeatherResponse getWeatherByCityId(@PathVariable("cityId") String cityId){
        WeatherResponse weatherResponse = weatherDataService.getDataByCityId(cityId);
        return weatherResponse;
    }

    @GetMapping("/cityName/{cityName}")
    public WeatherResponse getWeatherByCityName(@PathVariable("cityName") String cityName){
        WeatherResponse weatherResponse = weatherDataService.getDataByCityName(cityName);
        return weatherResponse;
    }
}
